package org.maggioni.springsandbox.rehearsals.e05aop.e01basic;


import org.maggioni.springsandbox.rehearsals.e05aop.e01basic.services.BusinessService;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class Main {

	public static void main(String[] args) {
		ApplicationContext applicationContext = new ClassPathXmlApplicationContext(Main.class.getName().replace(".","/")+"-applicationContext.xml");
		BusinessService businessService = applicationContext.getBean("businessService",BusinessService.class);
		
		System.out.println( "" );
		System.out.println( "---------------------------- BEGIN businessService.getBusinessObject().getField1()" );
		System.out.println( "businessService.getBusinessObject().getField1() : " + businessService.getBusinessObject().getField1() );
		System.out.println( "---------------------------- END   businessService.getBusinessObject().getField1()" );
		System.out.println( "" );
		System.out.println( "---------------------------- BEGIN businessService.getBusinessObject().setField2(\"newcustomfield2value\")" );
		businessService.getBusinessObject().setField2("newcustomfield2value");
		System.out.println( "---------------------------- END   businessService.getBusinessObject().setField2(\"newcustomfield2value\")" );
		System.out.println( "" );
		System.out.println( "---------------------------- BEGIN businessService.getBusinessObject().setFieldInt(10)" );
		businessService.getBusinessObject().setFieldInt(10);
		System.out.println( "---------------------------- END   businessService.getBusinessObject().setFieldInt(10)" );
		System.out.println( "" );
		System.out.println( "---------------------------- BEGIN businessService.doThrow().getField1()" );
		try {
			System.out.println( businessService.doThrow().getField1() );
		} catch (Exception e) {
			System.out.println("An exception has been arisen: "+e.getClass().getName());
		}
		System.out.println( "---------------------------- END   businessService.doThrow().getField1()" );
		System.out.println( "" );
		System.out.println( "---------------------------- BEGIN businessService.doThrow(false).getField1()" );
		System.out.println( businessService.doThrow(false).getField1() );
		System.out.println( "---------------------------- END   businessService.doThrow(false).getField1()" );
		System.out.println( "" );
		System.out.println( "---------------------------- BEGIN businessService.doThrowForAroundAdvice().getField1()" );
		try {
			System.out.println( businessService.doThrowForAroundAdvice().getField1() );
		} catch (Exception e) {
			System.out.println("An exception has been arisen: "+e.getClass().getName());
		}
		System.out.println( "---------------------------- END   businessService.doThrowForAroundAdvice().getField1()" );
		System.out.println( "" );
		System.out.println( "---------------------------- BEGIN businessService.doThrowForAroundAdvice(false).getField1()" );
		System.out.println( businessService.doThrowForAroundAdvice(false).getField1() );
		System.out.println( "---------------------------- END   businessService.doThrowForAroundAdvice(false).getField1()" );
		System.out.println( "" );

	}

}
